// 南航明珠商城-商品规格管理.js
 
function delSpecs(id){
    layer.confirm("确定删除此规格?",function(){
    	layer.closeAll('dialog');
    	var layer_load_window = layer.load(2); 
          $.ajax({
                url : path+"/specs/del_specs",
                cache : false,
                type : 'post',
                dataType : 'html',
                data : {
                    "id":id},
                error : function() {
                    layer.alert("操作失败!");
                },
                success : function(data) {
                    if (data== 'success') {
                        layer.msg('您的操作成功!',{icon:1,time:1000},function(){
                            $("#search_form").submit();
                        });
                    }else if(data== 'fail'){
                        layer.alert("您的操作失败!");
                    } else {
                    	 layer.alert(data);
                    }
                },complete: function(XMLHttpRequest, textStatus) {
                	layer.close(layer_load_window);
                }
          });
    });
}
 
function editSpecs(id,name){
    layer.prompt({
          formType: 2,
          value: name,
          title: '修改商品规格名称',
          area: ['400px'] //自定义文本域宽高
        }, function(value, index, elem){
        	layer.closeAll('dialog');
        	var layer_load_window = layer.load(2); 
          $.ajax({
                url : path+"/specs/edit_specs",
                cache : false,
                type : 'post',
                dataType : 'html',
                data : {
                    "id":id,
                    "name":value},
                error : function() {
                    layer.alert("操作失败!");
                },
                success : function(data) {
                    if (data== 'success') {
                        layer.msg('您的操作成功!',{icon:1,time:1000},function(){
                            $("#search_form").submit();
                        });
                    }else if(data== 'fail'){
                        layer.alert("您的操作失败!");
                    } else {
                    	layer.alert(data);
                    }
                },complete: function(XMLHttpRequest, textStatus) {
                	layer.close(layer_load_window);
                }
          });
          layer.close(index);
        });
}
 
function addSpecs(){
    layer.prompt({
          formType: 2,
          value: name,
          title: '添加新的商品规格名称',
          area: ['400px'] //自定义文本域宽高
        }, function(value, index, elem){
        	layer.closeAll('dialog');
        	var layer_load_window = layer.load(2); 
          $.ajax({
                url : path+"/specs/add_specs",
                cache : false,
                type : 'post',
                dataType : 'html',
                data : {
                    "name":value},
                error : function() {
                    layer.alert("操作失败!");
                },
                success : function(data) {
                    if (data== 'success') {
                        layer.msg('添加成功!',{icon:1,time:1000},function(){
                            $("#search_form").submit();
                        });
                    }else if(data== 'fail'){
                        layer.alert("您的操作失败!");
                    }else {
                    	layer.alert(data);
                    }
                },complete: function(XMLHttpRequest, textStatus) {
                	layer.close(layer_load_window);
                }
          });
          layer.close(index);
        });
}